package com.czt.mail.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author czt
 * @version 1.0
 * {@desc}
 * @date 2024/8/2 14:50
 */
@RestController
@RequestMapping("/redis")
public class RedisController {

    @Autowired
    private RedisTemplate<Object,Object> redisTemplate;

    /**
     * 生产者
     * @param msg 消息
     * @return
     */
    @GetMapping("/sendMsgChannel")
    public String sendMsgChannel(String msg) {
        //convertAndSend
        /*
        String channel    管道名称
        Object message    消息
         */
        redisTemplate.convertAndSend(SubscriberCfg.CHANNEL_NAME,msg);
        return "ok";
    }
}
